<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>认证审核</title>
    <!-- Le styles -->
    <link href="/common/js/bootstrap-3.0.0/css/bootstrap-united.min.css" rel="stylesheet">
    <style type="text/css">
        body {
            padding: 10px 0;
        }
    </style>
</head>
<body>
<div class="container">

    <form id="form" method="post" class="well form-horizontal">
        <fieldset>
            <legend>认证审核</legend>
            <div class="form-group">

                <div class="col-md-6">
                    <label class="col-md-4 control-label" for="roleName">认证类型</label>

                    <div class="col-md-8">

                        <select id="auth_type" name="auth_type" class="form-control">
                            <option value=""></option>
                        <#if authTypeList??>
                            <#list authTypeList as authType>
                                <option value="${authType.getCode()?string}">${authType.getName()}</option>
                            </#list>
                        </#if>
                        </select>
                    </div>
                </div>


                <div class="col-md-6">
                    <label class="col-md-4 control-label" for="roleName">审核状态</label>

                    <div class="col-md-8">

                        <select id="status" name="status" class="form-control">
                            <option value=""></option>
                            <option value="-1" selected>待认证</option>
                            <option value="1">认证通过</option>
                            <option value="2">认证未通过</option>
                        </select>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-12 text-right">
                    <button type="button" id="searchBtn" style="width: 80px;" class="btn btn-primary">查询</button>
                </div>
            </div>
        </fieldset>
    </form>

    <div class="col-md-12 text-right" style="margin:10px 0;">
        <#--<a style="width: 80px;" href="/user/addVerifyView" class="btn btn-success">新建</a>-->
    </div>

        <table id="resultTable" class="table table-bordered table-hover">
            <thead>
            <tr>
                <th>编号</th>
                <th>商家</th>
                <th>商家手机</th>
                <th>商家职业</th>
                <th>商家类型</th>
                <th>已通过认证</th>
                <th>认证图片</th>
                <th>名字</th>
                <th>认证类型</th>
                <th>状态</th>
                <th>描述</th>
                <th>详情</th>
            </tr>
            </thead>
            <tbody>
            <script type="text/html">
                <tr>
                    <td>{{id}}</td>
                    <td>{{user.cnName!''}}</td>
                    <td>{{user.mobile!''}}</td>
                    <td>{{user.bizWork.name!''}}</td>
                    <td>{{_self_data?renderUserType}}</td>
                    <td>{{authListStr!''}}</td>
                    <td>{{imgUrl?renderImg}}</td>
                    <td>{{name}}</td>
                    <td>{{authType?renderAuthType}}</td>
                    <td>{{status?renderStatus}}</td>
                    <td>{{descn!''}}</td>
                    <td>{{_self_data?renderOperation}}</td>
                </tr>
            </script>
            </tbody>
        </table>
</div>
<script type="text/javascript" src="/common/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="/common/js/bootstrap-table.20130913.js"></script>
<script type="text/javascript" src="/common/js/dateformat.js"></script>
<script type="text/javascript" src="/common/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
    $(function () {
        var param = $("#form").serialize();
        var s = $("#resultTable").bsTable({
            url: '/user/getVerifyList.json',
            ajaxType: "POST",  //ajax 提交方式 post 或者 get
            pageNo: 1,
            pageNoAlias: 'page',
            pageSize: 50,
            pageSizeAlias: 'pageSize',
            pagingAlign: "right",
            param: param,
            countRoot: "total",
            dataRoot: "list"
        });

        $("#searchBtn").on('click', function () {
            var param = $("#form").serialize();
            s.reload(param);
        });

        function search() {
            $("#searchBtn").click();
        }

//        window.onresize = function () {
//            window.top.autoIFrame();
//        }
    });

    function renderImg(imgUrl) {
        return "<a href=\"http://img.boyitongcheng.com/"+imgUrl+"\" target='_blank'><img src=\"http://img.boyitongcheng.com/"+imgUrl+"\" width=\"60px\" height=\"40px\"/></a>";
    }

    function renderStatus(status) {
        if (status == -1) {
            return "待认证";
        } else if(status == 1){
            return "认证通过";
        }else if(status == 2){
            return "认证未通过";
        }
    }

    function renderAuthType(authType) {
        if (authType == 1) {
            return "平台认证";
        } else if(authType == 2) {
            return "诚信认证";
        }else{
            return "学院认证";
        }
    }

    function renderOperation(row) {
        if (row && row.status == -1){
            return '<a style="width: 80px;margin: 3px 1px;" href="javascript:void(0);" onclick="passVerifyView(' + row.id + ', 1)" class="btn btn-success">审核通过</a>' +
                    '<a style="width: 100px;margin: 3px 1px;" href="/user/rejectVerifyView?id='+row.id+'&status=2" class="btn btn-info">审核不通过</a>';
        }else{
            return ""
        }
    }

    function renderUserType(row) {
        if (row){
            if (row.user.userType == 4){
                return "团队商家";
            }else if(row.user.userType == 3){
                return "普通商家";
            }
        }else{
            return ""
        }
    }

    <#--function renderUserVerify(row) {-->
        <#--if (row){-->
            <#--alert(row.userId);-->
            <#--&lt;#&ndash;return ${verifyMap[row.userId]!}&ndash;&gt;-->

            <#--<#list verifyMap?keys as key>-->
                <#--<#if key == row.userId>-->
                    <#--return ${verifyMap[key]}-->
                <#--</#if>-->
            <#--</#list>-->
        <#--}else{-->
            <#--return ""-->
        <#--}-->
    <#--}-->

    function passVerifyView(userId, status) {
        $.ajax({
            url: "/user/passVerifyView.json",
            type: "post",
            data: {id: userId, status: status},
            success: function (data) {
                if (data.msg == "FAIL") {
                    alert("操作失败！");
                } else {
                    alert("操作成功！");
                    $("#searchBtn").click();
//                    window.location.reload();
//                    search();
                }
            }
        });
    }

</script>
</body>
</html>